Home:ALL Converter>Problem using PROGMEM with pointer to an int array

Problem using PROGMEM with pointer to an int array

Ask Time:2020-02-24T01:08:47         Author:just4phil

Json Formatter

my arduino nano drives an LED Matrix. evrything works fine. but my "outline path" ist too big for the SRAM, so i try to put it into PROGMEM. Now reading values from this progmem array leads to totally wrong integers. what am i doing wrong?

thx for helping!!

bye andre

void progStarsWarp() {

const static PROGMEM int outlinePath[] = {30, 31, 29, 28, 27, 26, 36, 42, 43, 44, 45, 46, 25, 9, 8, 0, 1, 2, 4, 3, 16, 17, 56, 57, 91, 92, 101, 102, 111, 112, 121, 122, 162, 192, 193, 229, 230, 262, 263, 274, 275, 276, 277, 270, 269, 254, 239, 240, 241, 242, 243, 244, 253, 252, 251, 250, 249, 211, 210, 176, 177, 178, 179, 175, 161, 152, 151, 142, 141, 132, 131, 77, 72, 73, 74, 75, 76, 37, 31};
int *pointerOutlinePath;

FastLED.clear();

for (unsigned int i = 0; i < 79; i++) {
    pointerOutlinePath = &outlinePath[i];
    int test = pgm_read_word(pointerOutlinePath);
    leds.m_LED[outlinePath[test]] = CRGB(getRandomColorValue(), getRandomColorValue(), getRandomColorValue());
}

FastLED.show();
delay(60000);

}

Author:just4phil,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/60364701/problem-using-progmem-with-pointer-to-an-int-array
yy